package com.cs307.redcross.client;

import java.io.Serializable;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.SimplePanel;

public class ImageHeader extends Composite implements Serializable {
	public static Hyperlink hprlnkLogOut;
	@SuppressWarnings("deprecation")
	public ImageHeader() {
		
		FlowPanel flowPanel = new FlowPanel();
		initWidget(flowPanel);
		flowPanel.setSize("1124px", "81px");
		
		HorizontalPanel horizontalPanel = new HorizontalPanel();
		flowPanel.add(horizontalPanel);
		horizontalPanel.setWidth("1155px");
		
		Image image = new Image("images/lafayetteRedCross.png");
		horizontalPanel.add(image);
		image.setSize("198px", "77px");
		
		SimplePanel simplePanel = new SimplePanel();
		horizontalPanel.add(simplePanel);
		simplePanel.setSize("675px", "52px");
		
		hprlnkLogOut = new Hyperlink("Log Out", false, "newHistoryToken");
		horizontalPanel.add(hprlnkLogOut);
		hprlnkLogOut.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ContentPanel.getInstance().setContent(new LoginContent());
				RootPanel header;
				header = RootPanel.get("header");
				header.clear();
				Server.currentUser = null;
				
				hprlnkLogOut.setVisible(false);
				if ( Cookies.getCookie("sid") != null )
				{
					Cookies.removeCookie("sid"); 
				}
			}
		});
		hprlnkLogOut.setSize("82px", "23px");
		hprlnkLogOut.setVisible(false);
	}
	private static final long serialVersionUID = 7271003275700111752L;
}
